package cn.hsw.platform.core.validated.valid;

import cn.hsw.platform.core.util.Validator;
import cn.hsw.platform.core.validated.annotations.Password;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 密码校验
 * @author 李子木
 */
public class PasswordValid implements ConstraintValidator<Password,String> {
    @Override
    public void initialize(Password constraintAnnotation) {

    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {

        if(!Validator.isEmpty(s)) {
            return Validator.password(s);
        }else{
            return false;
        }
    }
}
